import 'package:flutter/material.dart';
import 'package:news_demo/View/NewValue/Widget/IndexWidget.dart';

import '../AttentionHomeIndex/ItmeIndex.dart';

class NewValue extends StatefulWidget {
  final String NewKey;
  NewValue({Key? key,required this.NewKey}) : super(key: key);

  @override
  State<NewValue> createState() => _NewValueState(NewKey:NewKey);
}

class _NewValueState extends State<NewValue> {

  final String NewKey;

  _NewValueState({required this.NewKey});

  bool bulidFlag=false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    //获取新闻数据（传入NewKey）
    //....
    print("initstate");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        leading: Container(
          child:GestureDetector(
            onTap: (){
              Navigator.pop(context);
            },
            child: Icon(Icons.arrow_circle_left,color: Colors.blue,size: 40),
          ),
        ),
        title: Container(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              //新闻日报图标
              GestureDetector(
                onTap: (){
                  Navigator.push(context, MaterialPageRoute(builder: (context)=>ItmeIndex(keys: "0",)));
                },
                child: Row(
                  children: [
                    Container(
                      height:40,
                      width: 40,
                      // padding: EdgeInsets.all(4),
                      child: Image.network("https://img0.baidu.com/it/u=1379004532,2711909750&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
                        fit: BoxFit.fill,),
                    ),
                    Container(
                      padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
                      child: Text("某某日报",style: TextStyle(
                        color: Colors.black,
                      ),),
                    ),
                  ],
                ),
              ),
              bulidFlag?
              Container(
                child: ElevatedButton(
                  style: ButtonStyle(
                      fixedSize: MaterialStateProperty.all(Size(100, 20)),
                      backgroundColor: MaterialStateProperty.all(Colors.black12)
                  ),
                  child: Text("已经关注"),
                  onPressed: (){
                    setState(() {
                      bulidFlag=!bulidFlag;
                    });
                  },
                ),
              ):
              Container(
                child: ElevatedButton(
                  style: ButtonStyle(
                    fixedSize: MaterialStateProperty.all(Size(100, 20))
                  ),
                  child: Text("关注"),
                  onPressed: (){
                    setState(() {
                      bulidFlag=!bulidFlag;
                    });
                  },
                ),
              ),
            ],
          ),
        ),
      ),
      body: Container(
        child: NewIndex(),
      ),
    );
  }
}
